<%@ page contentType="text/html; charset=UTF-8" language="java" %>
<%@ page import="com.base.myproject.server.tools.*" %>
<%@ page import="com.base.myproject.client.jdbc.DataSet,java.util.Date" %>
<%@page import="java.text.SimpleDateFormat,java.util.Calendar,java.math.BigDecimal"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns:x="urn:schemas-microsoft-com:office:excel">
<head>

<title></title>
<%
	String excel = request.getParameter("excel");
	if (excel != null && !excel.equals("")) {
		response.setHeader("Content-disposition","attachment; filename=SearchCard.xls");
	}
	String number = request.getParameter("number");
	String style = request.getParameter("style");
	String contract_id = request.getParameter("contract_id");
	String contract_addr = request.getParameter("contract_addr");
	String searchBeginDate = request.getParameter("searchBeginDate");
	String searchEndDate = request.getParameter("searchEndDate");
	String contract_begin = request.getParameter("contract_begin");
	String contract_end = request.getParameter("contract_end");
	
	DataSetTool DST = new DataSetTool();
	
	String sql = "select employno+bcode.bname as bname,hr_idCard.bcode,type,hr_idCard.idNo,addr,availableDate,passAvailableDate,issue,departments from  hr_idCard ,bcode, bcode_job  where bcode.bcode = bcode_job.bcode and bcode.bcode =hr_idCard.bcode and employstatus = '在职'";
	if (!number.equals("0")) {
		sql += " and hr_idCard.bcode like '%" + number + "%'";
	}
	
	if (!style.equals("0")) {
		sql += " and type like '%" + style + "%'";
	}
	if (!contract_id.equals("0")) {
		sql += " and hr_idCard.idNo like '%" + contract_id + "%'";
	}
	if (!contract_addr.equals("0")) {
		sql += " and addr like '%" + contract_addr + "%'";
	}
	if (!searchBeginDate.equals("0")) {
		sql += " and availableDate >= '" + searchBeginDate + "'";
	}
	if (!searchEndDate.equals("0")) {
		sql += " and availableDate <= '" + searchEndDate + "'";
	}
	if (!contract_begin.equals("0")) {
		sql += " and passAvailable >= '" + contract_begin + "'";
	}
	if (!contract_end.equals("0")) {
		sql += " and passAvailable <= '" + contract_end + "'";
	}
	
    sql += "order by availableDate asc";
	DataSet result = DST.getDataSet(sql);
%>
</head>

<body>

	<table style="border-collapse: collapse" border="1" align="center"  cellspacing="0" cellpadding="3" border="1" width="100%" bordercolordark="#CCCCCC" bordercolorlight="#CCCCCC" style="border-color:#000000;">
		<tr bgcolor="#e8e8e0" align="center" >
			<td>姓名编号</td>
			<td>所属部门</td>
			<td>证件类型</td>
			<td>证件号</td>
			<td>地址</td>
			<td>有效日期</td>
			<td>签证有效期</td>
			<td>签发机关</td>
		</tr>
		<%
			for(int i = 0;i < result.getRowCount();i++){
				
		%>
				<tr>
					<td><%= result.getValue(i,"bname") %></td>
					<td><%=result.getValue(i,"departments") %></td>
					<td><%=result.getValue(i,"type") %></td>
					<td x:str><%=result.getValue(i,"idNo") %></td>
					<td><%=result.getValue(i,"addr") %></td>
					<td><%=result.getValue(i,"availableDate") %></td>
					<td><%=result.getValue(i,"passAvailableDate") %></td>
					<td><%=result.getValue(i,"issue") %></td>
			</tr>
		<%		
			}
		%>
	</table>
</body>

</html>